/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: vtkImageSeedScan.h,v $

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkImageSeedScan - Create a binary image of a sphere.
// .SECTION Description
// vtkImageSeedScan is a helper class for connectivity filters.  
// It is not meant to be used directly.
// It implements a stack and breadth first search necessary for
// some connectivity filters.  Filtered axes sets the dimensionality 
// of the neighbor comparison, and
// cannot be more than three dimensions.  
// As implemented, only voxels which share faces are considered
// neighbors. 


#ifndef __vtkImageSeedScan_h
#define __vtkImageSeedScan_h

#include "vtkObject.h"

class vtkImageData;

//
// Special classes for manipulating data
//
//BTX - begin tcl exclude
//
// For the breadth first search
class vtkImageSeedScanSeed { //;prevent man page generation
public:
  static vtkImageSeedScanSeed *New() { return new vtkImageSeedScanSeed;}
  void *Pointer;
  int  Index[3];
  vtkImageSeedScanSeed *Next;
};
//ETX - end tcl exclude
//


class VTK_EXPORT vtkImageSeedScan : public vtkObject
{
public:
  static vtkImageSeedScan *New();

  vtkTypeRevisionMacro(vtkImageSeedScan,vtkObject);
  void PrintSelf(ostream& os, vtkIndent indent);

  //BTX
  vtkImageSeedScanSeed *NewSeed(int index[3], void *ptr);
  void AddSeed(vtkImageSeedScanSeed *seed);
  void AddSeedToEnd(vtkImageSeedScanSeed *seed);
  //ETX
  void RemoveAllSeeds();

  // Description:
  // Values used by the MarkRegion method
  vtkSetMacro(ConnectedValue, unsigned char); 
  vtkGetMacro(ConnectedValue, unsigned char);
  vtkSetMacro(UnconnectedValue, unsigned char);
  vtkGetMacro(UnconnectedValue, unsigned char);

  // Description:
  // Input a data of 0's and "UnconnectedValue"s. Seeds of this object are
  // used to find connected pixels.  All pixels connected to seeds are set to
  // ConnectedValue.  The data has to be unsigned char.
  void MarkData(vtkImageData *data,void(*function)(vtkImageData *data,vtkIdType cellId,void *arg),void *filter);
  void CheakData(vtkImageData *data,int marker[3][2],unsigned char bvalue);
  
  vtkIdType *GetIncrements(vtkImageData *data);	  

  bool IsNull(){return (this->Seeds==NULL);};
protected:
  vtkImageSeedScan();
  ~vtkImageSeedScan();

  unsigned char ConnectedValue;
  unsigned char UnconnectedValue;

  vtkImageSeedScanSeed *PopSeed();

  vtkImageSeedScanSeed *Seeds;
  vtkImageSeedScanSeed *LastSeed;

  vtkIdType Increments[3];
private:
  vtkImageSeedScan(const vtkImageSeedScan&);  // Not implemented.
  void operator=(const vtkImageSeedScan&);  // Not implemented.
};



#endif

  
